<?php
/*
 * @subpackage Core Pass input tag attributes as key value pairs. For a list of allowable attributes, see http://www.w3schools.com/tags/tag_input.asp @uses $vars['default'] The default value to submit if not checked. Optional, defaults to 0. Set to false for no default. @uses $vars['class'] Additional CSS class
 */
$star_url = elgg_normalize_url ( 'mod/subjectmanage/graphics/star.png' );
$star_url_half1 = elgg_normalize_url ( 'mod/subjectmanage/graphics/half-1.png' );
$star_url_half2 = elgg_normalize_url ( 'mod/subjectmanage/graphics/half-2.png' );

if (isset ( $vars ['class'] )) {
	$vars ['class'] = "elgg-input-checkbox {$vars['class']}";
} else {
	$vars ['class'] = "elgg-input-checkbox";
}

$defaults = array (
		'default' => 0,
		'disabled' => false 
);

$vars = array_merge ( $defaults, $vars );

$default = $vars ['default'];
unset ( $vars ['default'] );
$name = "";

if (isset ( $vars ['name'] )) {
	$name = $vars ['name'];
} else {
	$name = "rating";
}

if (isset ( $vars ['checked'] )) {
	switch ($vars ['checked']) {
		case 1 :
			$checked1 = "checked";
			break;
		case 2 :
			$checked2 = "checked";
			break;
		case 3 :
			$checked3 = "checked";
			break;
		case 4 :
			$checked4 = "checked";
			break;
		case 5 :
			$checked5 = "checked";
			break;
	}
}

echo <<<___HTML
<span class="rating">
    <input type="radio" class="rating-input"
        id="rating-input-1-5" value="5" $checked5 name="$name">
    <label for="rating-input-1-5" class="rating-star"></label>
    <input type="radio" class="rating-input"
        id="rating-input-1-4" value="4" $checked4 name="$name">
    <label for="rating-input-1-4" class="rating-star"></label>
    <input type="radio" class="rating-input"
        id="rating-input-1-3" value="3" $checked3 name="$name">
    <label for="rating-input-1-3" class="rating-star"></label>
    <input type="radio"  class="rating-input"
        id="rating-input-1-2" value="2" $checked2 name="$name">
    <label for="rating-input-1-2" class="rating-star"></label>
    <input type="radio" class="rating-input"
        id="rating-input-1-1" value="1" $checked1 name="$name">
    <label for="rating-input-1-1" class="rating-star"></label>
</span>
___HTML;

?>



<style>
.rating {
	overflow: hidden;
	display: inline-block;
}

.rating-input {
	display: none;
	position: absolute;
	left: 0;
	top: -50px;
}

.rating-star {
	display: block;
	width: 16px;
	height: 16px;
	background: url(<?php echo $star_url ?>) 0 -16px;
}

.rating-star:hover {
	background-position: 0 -16px;
}

.rating-star {
	float: right;
	display: block;
	width: 16px;
	height: 16px;
	background: url(<?php echo $star_url ?>) 0 -16px;
}

.rating-star:hover,.rating-star:hover  ~ .rating-star {
	background-position: 0 0;
}

.rating-star:hover,.rating-star:hover  ~ .rating-star,.rating-input:checked
     ~ .rating-star {
	background-position: 0 0;
}

.rating:hover .rating-star:hover,.rating:hover .rating-star:hover  ~
	.rating-star,.rating-input:checked  ~ .rating-star {
	background-position: 0 0;
}

.rating-star,.rating:hover .rating-star {
	float: right;
	display: block;
	width: 16px;
	height: 16px;
	background: url(<?php echo $star_url ?>) 0 -16px;
}

.rating-star-half {
	display: block;
	width: 8px;
	height: 16px;
	background: url(<?php echo $star_url ?>) 0 -16px;
}

.rating-star-half:hover {
	background-position: 0 0;
}

.rating-star-half {
	float: right;
	display: block;
	width: 8px;
	height: 16px;
	background: url(<?php echo $star_url ?>) 0 -16px;
}

.rating-star-half:hover,.rating-star:hover  ~ .rating-star-half {
	background-position: 0 0;
}

.rating-star-half:hover,.rating-star:hover  ~ .rating-star-half,.rating-input:checked
     ~ .rating-star-half {
	background-position: 0 0;
}

.rating:hover .rating-star-half:hover,.rating:hover .rating-star-half:hover 
	~ .rating-star-half,.rating-input:checked  ~ .rating-star-half {
	background-position: 0 0;
}

.rating-star-half,.rating:hover .rating-star-half {
	float: right;
	display: block;
	width: 8px;
	height: 16px;
	background: url(<?php echo $star_url ?>) 0 -16px;
}
</style>


